package com.zmx.common.common.utils;

import org.apache.commons.lang3.StringUtils;

import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * @Description: 用于String/Character/Integer/Long/List/Map/Set 类型判空
 * @ClassName: AllTypeUtil
 * @Author zhaomxr
 * @Date 2021-09-24 11:20
 */
public class AllTypeUtil {

    /**
     * String/Character/Integer/Long/List/Map/Set 判空
     *
     * @param object
     * @return
     */
    public boolean isEmpt(Object object) {
        if (object instanceof String || object instanceof Character) {
            return StringUtils.isEmpty(String.valueOf(object));
        } else if (object instanceof Integer || object instanceof Long) {
            return object == null;
        } else if (object instanceof List) {
            return object == null || ((List) object).size() == 0;
        } else if (object instanceof Map) {
            return object == null || ((Map) object).size() == 0;
        } else if (object instanceof Set) {
            return object == null || ((Set) object).size() == 0;
        }
        return true;
    }

    /**
     * String/Character/Integer/Long/List/Map/Set 判空
     *
     * @param object
     * @return
     */
    public boolean isBlank(Object object) {
        if (object instanceof String || object instanceof Character) {
            return StringUtils.isBlank(String.valueOf(object));
        } else if (object instanceof Integer || object instanceof Long) {
            return object == null;
        } else if (object instanceof List) {
            return object == null || ((List) object).size() == 0;
        } else if (object instanceof Map) {
            return object == null || ((Map) object).size() == 0;
        } else if (object instanceof Set) {
            return object == null || ((Set) object).size() == 0;
        }
        return true;
    }
}
